﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenTK;
using DDD.Core;
using DDD.OpenTK;
using FloatComparer = DDDTest.Helper.FloatComparer;

namespace DDDTest.OpenTK.TestVertexArray {
    [TestClass]
    public class TestCapture_ushort_ushort2_ushort3_ushort4_ {

        #region Field
        GameWindow window;
        #endregion

        #region Setup
        [TestInitialize ()]
        public void MyClassInitialize () {
            window = new GameWindow ();
        }

        [TestCleanup ()]
        public void MyClassCleanup () {
            window.Dispose ();
            window = null;
        }
        #endregion

        #region TestMethod
        [TestMethod]
        public void TestCapture_ushort () {
            var pos = new ushort[2] { 1, UInt16.MaxValue };
            var varry = new VertexArray<ushort> (2, 1);
            varry.Set (0, 2, pos);

            varry.Compile ();
            varry.Clear ();
            varry.Capture ();

            var buf = new ushort[2];
            varry.Get (0, 2, buf);

            CollectionAssert.AreEqual (pos, buf);
        }

        [TestMethod]
        public void TestCapture_ushort2 () {

            var pos = new ushort[4] { 1, 2, 3, UInt16.MaxValue };
            var varry = new VertexArray<ushort> (2, 2);
            varry.Set (0, 2, pos);

            varry.Compile ();
            varry.Clear ();
            varry.Capture ();

            var buf = new ushort[4];
            varry.Get (0, 2, buf);

            CollectionAssert.AreEqual (pos, buf);
        }

        [TestMethod]
        public void TestCapture_ushort3 () {

            var pos = new ushort[6] { 1, 2, 3, 4, 5, UInt16.MaxValue };
            var varry = new VertexArray<ushort> (2, 3);
            varry.Set (0, 2, pos);

            varry.Compile ();
            varry.Clear ();
            varry.Capture ();

            var buf = new ushort[6];
            varry.Get (0, 2, buf);

            CollectionAssert.AreEqual (pos, buf);
        }

        [TestMethod]
        public void TestCapture_ushort4 () {

            var pos = new ushort[8] { 1, 2, 3, 4, 5, 6, 7, UInt16.MaxValue };
            var varry = new VertexArray<ushort> (2, 4);
            varry.Set (0, 2, pos);

            varry.Compile ();
            varry.Clear ();
            varry.Capture ();

            var buf = new ushort[8];
            varry.Get (0, 2, buf);

            CollectionAssert.AreEqual (pos, buf);
        }
        #endregion

    }
}
